<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

</head>

<body>

    <script>

        let sx="sxz";

        let obj={ 

            name:"yuan",

            //属性

            sx,

            //与对象重名

            [sx]:"sxz's value",

            //动态属性，sx是一个变量，而放在中括号中就是sxz

            //就是把sx的值作为变量名

            sayname(){

                console.log(this.name)

                //对象属性必须加this

            },

            saydsx(){

                console.log(this.sxz)

            }

        }

        console.log(obj.name);

        console.log(obj.sx);

        console.log(obj.sxz);

        obj.sayname();

        obj.saydsx();

    </script>

</body>

</html>